#ifndef MYDEVICE_H
#define MYDEVICE_H


#include "pinctrl.h"
#include "soc_osal.h"
#include "uart.h"
#include "watchdog.h"
#include "osal_debug.h"
#include "cmsis_os2.h"
#include "app_init.h"
#include "gpio.h"
#define SLE_LOG                 "[SLE]"
#define RGB_LOG                 "[RGB]"
#define FAN_LOG                 "[FAN]"
#define UART_LOG                "[UART]"

#define UART_BAUDRATE                      115200
#define UART_DATA_BITS                     3
#define UART_STOP_BITS                     1
#define UART_PARITY_BIT                    0
#define UART_TRANSFER_SIZE                 512

#define VREF 3300.0f // 参考电压（mV）

typedef struct SensorData
{
    char ligBuffer[10];
    char humidity[10];
    char temperature[10];
    char soilHum[10];
    int id;
}SensorData;
typedef struct {
    char fanFlag[2];       // 存储 "0" 或 "1"
    char waterFlag[2];
    char sunFlag[2];
    char switchFlag[2];
    char colorNum[3][3];   // 存储 r, g, b 值，每个值最多 2 个字符加一个空字符
} ControlState;
// extern SensorData othData;
// typedef unsigned int uint16_10t;
void uart_gpio_init(uint16_t uart_bus,uint16_t uart_tx,uint16_t uart_rx );
void uart_init_config(uint16_t uart_bus,uint16_t uart_tx,uint16_t uart_rx,uart_buffer_config_t* buff_config);


void light_data_treating(uint8_t ch, uint32_t *buffer, uint32_t length, bool *next,SensorData* Data);
void soilHum_data_treating(uint8_t ch, uint32_t *buffer, uint32_t length, bool *next,SensorData* Data);

void init_water(void);
void water_control(bool flag);
void init_fan(void);
void set_fan_in(void);
void set_fan_out(void);
void set_fan_stop(void);
void control(ControlState* conData);

#endif 